<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="模板编号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="编制日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="模板状态">
              <el-select v-model="dataForm.FBILLTYPE" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>


        <el-col :span="16">
          <el-form-item label="模板名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="编制人员" prop="FUSER">
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>

       <el-col :span="8">
          <el-form-item label="评价总分" prop="FTOTAL">
            <el-input v-model="dataForm.FTOTAL"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="及格分数" prop="FBAD">
            <el-input v-model="dataForm.FBAD"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="优秀分数" prop="FGOOD">
            <el-input v-model="dataForm.FGOOD"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="16">
          <el-form-item label="模板备注" prop="FNOTE">
            <el-input v-model="dataForm.FNOTE"   />
          </el-form-item>
        </el-col>
        

        <el-col :span="5">
          <el-form-item label="">
            <el-button type="success" icon="el-icon-plus" @click="insert">添加</el-button>
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85" ></el-table-column>
      <el-table-column prop="FCATTYPE" label="评测分类" ></el-table-column>
      <el-table-column prop="FITEM" label="评测项目" ></el-table-column>
      <el-table-column prop="FPOINT" label="评分"></el-table-column>
      <el-table-column prop="FMEMMO" label="备注" ></el-table-column>
    </el-table>
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FBILLNO :"MJ250101",
          FCATNAME:"2025年基地评价模板",
          FUSER: "曹操",
          FUSERTYPE:"本院人员",
          FBILLCREDATE: "2024-11-25",
          FMEMO: "",
          FBEGDATE: "2024-12-01",
          FENDDATE: "2025-11-30",
          FCHECKUSE: "汉武帝",
          FBILLTYPE: "正常",
          FBILLSTATE: "正常",
          FCHECKDATE: "",
          FNOTE: "",
          FTOTAL:100, 
          FBAD :60,
          FGOOD:90
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FCATTYPE": "1.基地环境",
                  "FITEM":"",
                  "FPOINT": "",
                  "FMEMMO": ""
                },
                { "FENTRYID":2,
                  "FCATTYPE": "",
                  "FITEM":"-安全措施是否到位",
                  "FPOINT": "1,2,3,4,5",
                  "FMEMMO": ""
                },
                { "FENTRYID":3,
                  "FCATTYPE": "",
                  "FITEM":"-设施是否全部能用",
                  "FPOINT": "1,2,3,4,5",
                  "FMEMMO": ""
                },
                {  "FENTRYID":4,
                  "FCATTYPE": "2.服务质量",
                  "FITEM":"",
                  "FPOINT": "",
                  "FMEMMO": ""
                },
                { "FENTRYID":5,
                  "FCATTYPE": "",
                  "FITEM":"-工作人员专业素养",
                  "FPOINT": "1,2,3,4,5",
                  "FMEMMO": ""
                },
                { "FENTRYID":6,
                  "FCATTYPE": "",
                  "FITEM":"-设施使用说明详细",
                  "FPOINT": "1,2,3,4,5",
                  "FMEMMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '正常'
        }, {
          value: '2',
          label: '作废'
        }],

        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>